
/**
 * 新增 修改
 * 接口json
 * 返回json 必须要有status以及notice
 */
function postsave(url,param,href=""){
  $.post(url,param,function(data){
	  if(data.status == 1){
		  if(href){
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
				  window.location.href=href;
				}
			  });
		  } else {
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
					history.go(0);
				}
			  });
		  }
	  } else {
		$.notify({
			title: "",
			message: data.notice,
			icon: 'fa fa-close' 
		},{
			type: "info"
		});
	  }
  },'json');
}

/**
 * 删除
 * 接口json
 * 返回json 必须要有status以及notice
 */
function postdelete(url,param,href){
	swal({
		title: "你确定删除吗?",
		text: "",
		type: "warning",
		showCancelButton: true,
		confirmButtonText: "确定操作",
		cancelButtonText: "考虑一下",
		closeOnConfirm: false,
		closeOnCancel: true
	}, function(isConfirm) {
		if (isConfirm) {
			$.post(url,param,function(data){
				if(data.status == 1){
				  if(href){
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
						  window.location.href=href;
						}
					  });
				  } else {
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
							history.go(0);
						}
					  });
				  }
				} else {
				  swal({ 
					title:data.notice, 
					type: "error",
				  },function(isConfirm){
					if(isConfirm){
						history.go(0);
					}
				  });

				  /*
				  $.notify({
				  	title: "",
				  	message: data.notice,
				  	icon: 'fa fa-close' 
				  },{
				  	type: "info"
				  });
				  */
			  }
			},'json');
		}
	});
}


/**
 * 确认操作
 * 接口json
 * 返回json 必须要有status以及notice
 */
function confirmpost(url,param,href,notice){
	swal({
		title: notice,
		text: "",
		type: "warning",
		showCancelButton: true,
		confirmButtonText: "确定操作",
		cancelButtonText: "考虑一下",
		closeOnConfirm: false,
		closeOnCancel: true
	}, function(isConfirm) {
		if (isConfirm) {
			$.post(url,param,function(data){
				if(data.status == 1){
				  if(href){
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
						  window.location.href=href;
						}
					  });
				  } else {
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
							history.go(0);
						}
					  });
				  }
				} else {
				  swal({ 
					title:data.notice, 
					type: "error",
				  },function(isConfirm){
					if(isConfirm){
						history.go(0);
					}
				  });
			  }
			},'json');
		}
	});
}

/**
 * ajax post
 * 接口json
 * 返回json 必须要有status以及notice
 */
function ajaxpost(url,param,href=""){
  $.post(url,param,function(data){
	  if(data.status == 1){
		  if(href){
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
				  window.location.href=href;
				}
			  });
		  } else {
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
					history.go(0);
				}
			  });
		  }
	  } else {
		$.notify({
			title: "",
			message: data.notice,
			icon: 'fa fa-close' 
		},{
			type: "info"
		});
	  }
  },'json');
}

/**
 * 确认操作
 * 接口json
 * 返回json 必须要有status以及notice
 */
function confirmpost(url,param,href,notice){
	swal({
		title: notice,
		text: "",
		type: "warning",
		showCancelButton: true,
		confirmButtonText: "确定操作",
		cancelButtonText: "考虑一下",
		closeOnConfirm: false,
		closeOnCancel: true
	}, function(isConfirm) {
		if (isConfirm) {
			$.post(url,param,function(data){
				if(data.status == 1){
				  if(href){
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
						  window.location.href=href;
						}
					  });
				  } else {
					  swal({ 
						title:data.notice, 
						type: "success",
					  },function(isConfirm){
						if(isConfirm){
							history.go(0);
						}
					  });
				  }
				} else {
				  swal({ 
					title:data.notice, 
					type: "error",
				  },function(isConfirm){
					if(isConfirm){
						history.go(0);
					}
				  });
			  }
			},'json');
		}
	});
}

/**
 * ajax post
 * 接口json
 * 返回json 必须要有status以及notice
 */
function ajaxpost(url,param,href=""){
  $.post(url,param,function(data){
	  if(data.status == 1){
		  if(href){
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
				  window.location.href=href;
				}
			  });
		  } else {
			  swal({ 
				title:data.notice, 
				type: "success",
			  },function(isConfirm){
				if(isConfirm){
					history.go(0);
				}
			  });
		  }
	  } else {
		$.notify({
			title: "",
			message: data.notice,
			icon: 'fa fa-close' 
		},{
			type: "info"
		});
	  }
  },'json');
}
